/**
 * 
 */
package com.zito.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.downlove.common.LinkTool;
import com.downlove.common.Storage.FileInfo;
import com.downlove.common.Storage.ImageInfo;
import com.downlove.template.freemarker.FreeMarkerEngine;
import com.zito.bean.Admin;
import com.zito.bean.Columnz;
import com.zito.bean.Investoption;
import com.zito.bean.Investques;
import com.zito.bean.Weblink;
import com.zito.manager.AdsManager;
import com.zito.manager.AdviceManager;
import com.zito.manager.AlbumManager;
import com.zito.manager.AlbumphotoManager;
import com.zito.manager.ArticleManager;
import com.zito.manager.ArticlefilesManager;
import com.zito.manager.ArticlephotosManager;
import com.zito.manager.ColumnManager;
import com.zito.manager.ContributeManager;
import com.zito.manager.InvestManager;
import com.zito.manager.MasterManager;
import com.zito.manager.PartyBuildingManager;
import com.zito.manager.VideoManager;
import com.zito.manager.WeblinkManager;

/**
 * @author YunHai-Home
 * 
 */
public class MasterAction {
	private String message = "";
	private String jumpUrl = "";
	
	/**
	 * 管理员登录
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean login(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		MasterManager obj = new MasterManager();
		boolean re = false;
		try {
			re = obj.authAdmin();
		} catch (Exception e) {
			message = e.getMessage();
		}
		jumpUrl = "/master/index";
		fm.put("success", re);
		fm.put("message", message);
		fm.put("jump", jumpUrl);

		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 添加管理员
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean addMaster(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		MasterManager obj = new MasterManager();
		boolean re = false;
		Admin admin = new Admin();
		try {
			admin = obj.addMaster();
			re = (admin != null);
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("jump", jumpUrl);
		fm.put("temp", admin.getId());
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 删除管理员帐号
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean removeMaster(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		MasterManager obj = new MasterManager();
		boolean re = false;
		try {
			re = obj.removeMaster();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 修改管理员登录密码
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean editMaster(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		MasterManager obj = new MasterManager();
		boolean re = false;
		try {
			re = obj.editMaster();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 添加一个专题
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean addColumns(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ColumnManager obj = new ColumnManager();
		boolean re = false;
		Columnz column = new Columnz();
		message = "专题添加成功！您可以继续添加新专题。页面刷新后将显示新的改动。";
		try {
			column = obj.addColumns();
			re = (column != null);
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("temp", column.getId());
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 删除一个专题
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean deleteColumns(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ColumnManager obj = new ColumnManager();
		boolean re = false;
		try {
			re = obj.deleteCoumns();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 编辑专题
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean editColumns(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ColumnManager obj = new ColumnManager();
		boolean re = false;
		message = "专题编辑成功！页面刷新后将显示改动";
		try {
			re = obj.editCoumns();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 文章图片上传
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean ArticleImageUpload(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticlephotosManager obj = new ArticlephotosManager();
		boolean re = false;
		// ImageInfo info = new ImageInfo();
		message = "图片上传成功";
		Long tmpFileID = -1L;
		try {
			Map<String, Object> tmpInfo = obj.uploadImages();
			tmpFileID = (Long) tmpInfo.get("tmpFileid");
			ImageInfo info = (ImageInfo) tmpInfo.get("info");
			if (info != null) {
				fm.put("filenames", info.getImageName());
				fm.put("originalnames", info.getImageOriginalName());
				fm.put("filepath", LinkTool.images(info.getImagePath()));
			}
			re = (info == null) ? false : true;
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "上传图片出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("fileid", tmpFileID);

		FreeMarkerEngine.action(fm, "uploadfile.html");
		return true;
	}

	/**
	 * 上传文章中的附件
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean ArticleFileUpload(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticlefilesManager obj = new ArticlefilesManager();
		boolean re = false;
		message = "附件上传成功";
		Long tmpFileID = -1L;
		try {
			Map<String, Object> tmpInfo = obj.uploadFiles();
			tmpFileID = (Long) tmpInfo.get("tmpFileid");
			FileInfo info = (FileInfo) tmpInfo.get("info");
			if (info != null) {
				fm.put("filenames", info.getFileName());
				fm.put("originalnames", info.getFileOriginalName());
				fm.put("filepath", LinkTool.files(info.getFilePath()));
			}
			re = (info == null) ? false : true;
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("fileid", tmpFileID);

		FreeMarkerEngine.action(fm, "uploadfile.html");
		return true;
	}

	/**
	 * 删除一个文章图片
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean deleteArticlePhoto(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticlephotosManager obj = new ArticlephotosManager();
		boolean re = false;
		message = "图片删除成功";
		try {
			re = obj.deleteOneArticlePhoto();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 删除文章中的一个附件
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean deleteArticleFile(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticlefilesManager obj = new ArticlefilesManager();
		boolean re = false;
		message = "附件删除成功";
		try {
			re = obj.deleteOneArticleFile();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 提交并保存文章，可响应添加和编辑文章事件
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean ArticleEdit(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticleManager obj = new ArticleManager();
		boolean re = false;
		message = "文章发布成功，您可以清空表单后继续添加新的文章";
		try {
			re = obj.operatingPost();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 文章删除
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean DeleteArticle(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticleManager obj = new ArticleManager();
		boolean re = false;
		message = "文章删除成功！";
		try {
			re = obj.deleteArticle();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}
	
	/**
	 * 文章置顶
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean setArticleTopic(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticleManager obj = new ArticleManager();
		boolean re = false;
		message = "文章置顶成功";
		try {
			re = obj.setTopic();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/***
	 * 文章取消置顶
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean unArticleTopic(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ArticleManager obj = new ArticleManager();
		boolean re = false;
		message = "文章取消置顶成功";
		try {
			re = obj.unTopic();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 相册图片上传
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean AlbumImageUpload(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AlbumphotoManager obj = new AlbumphotoManager();
		boolean re = false;
		// ImageInfo info = new ImageInfo();
		message = "图片上传成功";
		Long tmpFileID = -1L;
		try {
			Map<String, Object> tmpInfo = obj.uploadImages();
			tmpFileID = (Long) tmpInfo.get("tmpFileid");
			// System.out.println("tmpFileID : "+ tmpFileID);
			ImageInfo info = (ImageInfo) tmpInfo.get("info");
			if (info != null) {
				fm.put("filenames", info.getImageThumbName());
				fm.put("originalnames", info.getImageOriginalName());
				fm.put("filepath", LinkTool.images(info.getImageThumbPath()));
			}
			re = (info == null) ? false : true;
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "上传图片出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("fileid", tmpFileID);

		FreeMarkerEngine.action(fm, "uploadfile.html");
		return true;
	}

	/**
	 * 删除一个图集图片
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean deleteAlbumPhoto(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AlbumphotoManager obj = new AlbumphotoManager();
		boolean re = false;
		message = "图片删除成功";
		try {
			re = obj.deleteOneAlbumphoto();
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "图片删除出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 保存图集信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean AlbumSave(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AlbumManager obj = new AlbumManager();
		boolean re = false;
		message = "图集编辑成功！";
		try {
			re = obj.operatingPost();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 删除指定图集
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean deleteAlbum(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AlbumManager obj = new AlbumManager();
		boolean re = false;
		message = "图集删除成功";
		try {
			re = obj.deleteAlbum();
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "图集删除出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 视频封面图片上传
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public void VideoImageUpload(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		VideoManager obj = new VideoManager();
		boolean re = false;
		message = "图片上传成功";
		try {
			ImageInfo info = obj.uploadImages();
			if (info != null) {
				fm.put("filenames", info.getImageName());
				fm.put("originalnames", info.getImageOriginalName());
				fm.put("filepath", LinkTool.images(info.getImagePath()));
			}
			re = (info == null) ? false : true;
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "上传图片出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "uploadfile.html");
	}

	/**
	 * 保存视频信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public void VideoSave(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		VideoManager obj = new VideoManager();
		boolean re = false;
		message = "保存成功！";
		try {
			re = obj.operatingPost();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 机关党建专版电子版编辑
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean PartyBuildingEdit(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		PartyBuildingManager obj = new PartyBuildingManager();
		boolean re = false;
		message = "机关党建专版发布成功，您可以清空表单后继续添加新的机关党建专版";
		try {
			re = obj.operatingPost();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}
	
	
	/**
	 * 机关党建专版电子版删除
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean DeletePartyBuilding(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		PartyBuildingManager obj = new PartyBuildingManager();
		boolean re = false;
		message = "文章删除成功！";
		try {
			re = obj.deletePartyBuilding();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}
	
	/**
	 * 获取问卷问题列表
	 * @param request
	 * @param response
	 * @return
	 */
	public void GetInvestQuesList(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		List<Investques> list = new ArrayList<Investques>();
		try {
			list = obj.getInvestQuesList();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("ListData", list);
		FreeMarkerEngine.action(fm, "master/data/InvestQuesList.ftl");
	}
	
	/**
	 * 获取问卷问题选项列表
	 * @param request
	 * @param response
	 * @return
	 */
	public void GetInvestOptionList(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		List<Investoption> list = new ArrayList<Investoption>();
		try {
			list = obj.getInvestOptionList();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("ListData", list);
		FreeMarkerEngine.action(fm, "master/data/InvestOptionList.ftl");
	}
	
	/**
	 * 问卷启用
	 * @param request
	 * @param response
	 * @return
	 */
	public void setInvestStatus(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "设置成功！";
		try {
			re = obj.setStatus();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 问卷停用
	 * @param request
	 * @param response
	 * @return
	 */
	public void unInvestStatus(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "设置成功！";
		try {
			re = obj.unStatus();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 保存问卷
	 * @param request
	 * @param response
	 * @return
	 */
	public void SaveInvest(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		Long id = -1L;
		message = "保存成功！";
		try {
			id = obj.saveInvest();
			re = id>0;
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("temp", id);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 保存问卷问题
	 * @param request
	 * @param response
	 * @return
	 */
	public void SaveInvestQues(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "保存成功！";
		try {
			re = obj.saveInvestQues();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 保存问题选项
	 * @param request
	 * @param response
	 * @return
	 */
	public void SaveInvestOption(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "保存成功！";
		try {
			re = obj.saveInvestOption();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 问卷删除
	 * @param request
	 * @param response
	 * @return
	 */
	public void DeleteInvest(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "删除成功！";
		try {
			re = obj.deleteInvest();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 问卷问题删除
	 * @param request
	 * @param response
	 * @return
	 */
	public void DeleteInvestQues(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "删除成功！";
		try {
			re = obj.deleteInvestQues();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 问题选项删除
	 * @param request
	 * @param response
	 * @return
	 */
	public void DeleteInvestOption(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		InvestManager obj = new InvestManager();
		boolean re = false;
		message = "删除成功！";
		try {
			re = obj.deleteInvestOption();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 用户投稿保存
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public void SaveContributeEdit(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ContributeManager obj = new ContributeManager();
		boolean re = false;
		message = "保存成功！";
		try {
			re = obj.SaveManageEdit();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}

	/**
	 * 删除投稿
	 * @param request
	 * @param response
	 * @return
	 */
	public void DeleteContribute(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		ContributeManager obj = new ContributeManager();
		boolean re = false;
		message = "删除成功！";
		try {
			re = obj.ContributeManageDelete();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 党员投诉管理员回复 保存
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public void SaveAdviceEdit(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AdviceManager obj = new AdviceManager();
		boolean re = false;
		message = "保存成功！";
		try {
			re = obj.SaveAdviceEdit();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 删除投诉
	 * @param request
	 * @param response
	 * @return
	 */
	public void DeleteAdvice(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AdviceManager obj = new AdviceManager();
		boolean re = false;
		message = "删除成功！";
		try {
			re = obj.deleteAdvice();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
	}
	
	/**
	 * 添加一个友情链接
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean AddWebLink(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		WeblinkManager obj = new WeblinkManager();
		boolean re = false;
		message = "友情链接添加成功！";
		Weblink link = new Weblink();
		try {
			link = obj.addLink();
			re = (link != null);
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		fm.put("temp", link.getId());
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 删除一个友情链接
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean DeleteWebLink(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		WeblinkManager obj = new WeblinkManager();
		boolean re = false;
		message = "友情链接删除成功！";
		try {
			re = obj.deleteTextLink();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 编辑一个友情链接
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean EditWebLink(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		WeblinkManager obj = new WeblinkManager();
		boolean re = false;
		message = "友情链接修改成功！";
		try {
			re = obj.updateTextLink();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 友情链接LOGO上传
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean WebLinkLogoUpload(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		WeblinkManager obj = new WeblinkManager();
		boolean re = false;
		message = "LOGO上传成功";
		try {
			ImageInfo tmpInfo = obj.uploadLOGO();
			if (tmpInfo != null) {
				fm.put("filenames", tmpInfo.getImageName());
				fm.put("originalnames", tmpInfo.getImageOriginalName());
				fm.put("filepath", LinkTool.upload(tmpInfo.getImagePath()));
			}
			re = (tmpInfo == null) ? false : true;
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "上传LOGO出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "uploadfile.html");
		return true;
	}

	/**
	 * 广告文件上传
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean AdsFileUpload(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AdsManager obj = new AdsManager();
		boolean re = false;
		message = "广告文件上传成功";
		try {
			FileInfo tmpInfo = obj.uploadFile();
			if (tmpInfo != null) {
				fm.put("filenames", tmpInfo.getFileName());
				fm.put("originalnames", tmpInfo.getFileOriginalName());
				fm.put("filepath", LinkTool.upload(tmpInfo.getFilePath()));
			}
			re = (tmpInfo == null) ? false : true;
		} catch (Exception e) {
			message = e.getMessage();
			if (message == null || "".equals(message))
				message = "上传文件出现未知错误，请及时联系管理人员！";
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "uploadfile.html");
		return true;
	}

	/**
	 * 提交并保存广告信息，可响应添加和编辑事件
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean adsSave(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AdsManager obj = new AdsManager();
		boolean re = false;
		message = "广告发布成功，您可以广告列表中设置广告的显示";
		try {
			re = obj.operatingPost();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/***
	 * 广告激活
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean AdsActive(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AdsManager obj = new AdsManager();
		boolean re = false;
		message = "广告激活成功，您可以首页看到该广告的显示";
		try {
			re = obj.adsActive();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}

	/**
	 * 删除广告
	 * @param request
	 * @param response
	 * @return
	 */
	public boolean deleteAds(HttpServletRequest request,
			HttpServletResponse response) {
		FreeMarkerEngine fm = new FreeMarkerEngine(request, response);
		AdsManager obj = new AdsManager();
		boolean re = false;
		message = "广告删除成功";
		try {
			re = obj.deleteAds();
		} catch (Exception e) {
			message = e.getMessage();
		}
		fm.put("success", re);
		fm.put("message", message);
		FreeMarkerEngine.action(fm, "submit.html");
		return true;
	}
}
